package com.sumer.thread;

/**
 * yield()方法暂停当前正在执行的线程，线程状态由运行状态变为就绪状态。
 */
public class ThreadYield implements Runnable {


    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "线程开始");
        Thread.yield();
        System.out.println(Thread.currentThread().getName() + "线程结束");
    }

    public static void main(String[] args) {
        ThreadYield threadYield = new ThreadYield();
        new Thread(threadYield,"a").start();
        new Thread(threadYield,"b").start();
    }
}

